from PySide6.QtWidgets import QWidget, QVBoxLayout, QLabel, QFrame
from PySide6.QtCore import Qt

class ControlInfoPanel(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setup_ui()
        
    def setup_ui(self):
        control_outer_layout = QVBoxLayout(self)
        control_outer_layout.setAlignment(Qt.AlignCenter)
        
        # 创建一个固定大小的容器框架
        self.control_container = QFrame()
        self.control_container.setFixedSize(180, 180)
        self.control_container.setFrameShape(QFrame.StyledPanel)
        self.control_container.setStyleSheet("background-color: #f0f0f0; border: 1px solid #cccccc;")
        
        # 将控制信息容器添加到外部容器中
        control_outer_layout.addWidget(self.control_container)
        
        # 控制信息区域使用相对布局
        control_layout = QVBoxLayout(self.control_container)
        control_layout.setContentsMargins(5, 5, 5, 5)
        control_layout.setSpacing(5)
        
        # 创建摇杆信息标签
        self.left_joystick_label = QLabel("左摇杆: X: 0, Y: 0")
        self.right_joystick_label = QLabel("右摇杆: X: 0, Y: 0")
        
        # 设置标签样式
        label_style = "font-size: 14px; font-weight: bold; color: #333333;"
        self.left_joystick_label.setStyleSheet(label_style)
        self.right_joystick_label.setStyleSheet(label_style)
        
        # 添加标签到布局
        control_layout.addWidget(self.left_joystick_label)
        control_layout.addWidget(self.right_joystick_label)
        
    def update_joystick_info(self, left_x, left_y, right_x, right_y):
        """更新摇杆信息显示"""
        self.left_joystick_label.setText(f"左摇杆: X: {left_x:.2f}, Y: {left_y:.2f}")
        self.right_joystick_label.setText(f"右摇杆: X: {right_x:.2f}, Y: {right_y:.2f}") 